package org.spdata.tsdb.dto;

import java.util.LinkedHashMap;

/**
 * 某个采样值
 */
public class DataPoint {
	/**
	 * 测点id,该属性由tsdb-server赋值
	 */
	private Integer metricId;
	
	/**
	 * 测点
	 */
	private String metric;
	
	/**
	 * 测点的tag，tag和metric组合时要保证唯一性
	 */
	private LinkedHashMap<String,String> tags;
	
	/**
	 * 采样时间
	 */
	private Long time;
	
	/**
	 * 采样值,可以是float或者int
	 */
	private Number value;
	
	public DataPoint() {
	}
	
	public DataPoint(String metric, LinkedHashMap<String,String> tags ,long sampleAt, float value) {
		this.metric = metric;
		this.time = sampleAt;
		this.value = value;
		this.tags = tags;
	}

	public LinkedHashMap<String, String> getTags() {
		return tags;
	}

	public void setTags(LinkedHashMap<String, String> tags) {
		this.tags = tags;
	}
	
	public void addTag(String tagName,String tagValue) {
		if(this.tags==null)
			this.tags = new LinkedHashMap<String,String>();
		this.tags.put(tagName, tagValue);
	}
	public Number getValue() {
		return value;
	}
	
	public void setValue(Number value) {
		this.value = value;
	}
	
	public Long getTime() {
		return time;
	}
	
	public void setTime(Long time) {
		this.time = time;
	}

	
	public Integer getMetricId() {
		return metricId;
	}

	public void setMetricId(Integer metricId) {
		this.metricId = metricId;
	}

	public String getMetric() {
		return metric;
	}

	public void setMetric(String metric) {
		this.metric = metric;
	}

	@Override
	public String toString() {
		return "DataPoint [metricId=" + metricId + ", metric=" + metric + ", tags=" + tags + ", time=" + time
				+ ", value=" + value + "]";
	}
	
}
